home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / ecstr2.arc / STRINGS.H < prev    next >
C/C++ Source or Header  |  1987-03-04  |  6KB  |  161 lines

  1. /*  File   : strings.h
  2.     Author : Richard A. O'Keefe.
  3.     Updated: 1 June 1984
  4.     Purpose: Header file for the "string(3C)" package.
  5.  
  6.     All  the  routines  in  this  package  are  the  original  work   of
  7.     R.A.O'Keefe.   Any  resemblance  between  them  and  any routines in
  8.     licensed software is due entirely  to  these  routines  having  been
  9.     written  using the "man 3 string" UNIX manual page, or in some cases
  10.     the "man 1 sort" manual page as a specification.  See the READ-ME to
  11.     find the conditions under which these routines may be used & copied.
  12. */
  13.  
  14. #ifndef        NullS
  15. #define        NullS   (char*)0
  16. #define NUL    '\0'
  17.  
  18. /*  MAKE SURE THE RIGHT VERSION OF THE FOLLOWING MACRO IS INSTALLED!  */
  19.  
  20. #if    vax | pdp11 | m68000 | perq
  21. #define CharsAreSigned 1                       /* default is unsigned */
  22. #endif vax | pdp11 | m68000 | perq
  23.  
  24. #if    CharsAreSigned
  25. #define int2char(i)  (((i)<<((sizeof (int) -1)*8))>>((sizeof (int) -1)*8))
  26. #else  !CharsAreSigned
  27. #define        int2char(i)     ((i)&255)
  28. #endif CharsAreSigned
  29. /*  If characters are signed, but the above doesn't work,
  30.     try      ((127-(255&~(i)))^(-128))
  31. */
  32.  
  33. #ifndef        _AlphabetSize
  34. #define        _AlphabetSize   128
  35. #endif
  36.  
  37. #if    _AlphabetSize == 128
  38. typedef        char _char_;
  39. #endif
  40. #if    _AlphabetSize == 256
  41. typedef        unsigned char _char_;
  42. #endif
  43.  
  44. /*  NullS is the "nil" character  pointer.   NULL  would  work  in  most
  45.     cases,  but  in  some  C  compilers  pointers and integers may be of
  46.     different sizes, so it is handy to have a nil pointer that  one  can
  47.     pass to a function as well as compare pointers against.
  48.  
  49.     NUL is the ASCII name for the character with code 0.  Its use to end
  50.     strings is a convention of the C programming language.  There are in
  51.     fact three different end of string conventions supported by routines
  52.     in this package:
  53.      str<opn>        : end at the first NUL character
  54.        strn<opn>       : end at the first NUL character, or when the
  55.                          extra "len" parameter runs out.
  56.        mem<opn>,b<opn> : length determined solely by "len" parameter.
  57.     Unfortunately, the VAX hardware only supports the last convention, a
  58.     pity really.  Fortran 77 users BEWARE: Fortran 77's convention is an
  59.     entirely different one, and there are NO routines in this package as
  60.     yet which support it.  (But see section 3F of the 4.2 BSD manual.)
  61.  
  62.     The routines which move characters around don't  care  whether  they
  63.     are  signed or unsigned.  But the routines which compare a character
  64.     in a string with an argument, or use a character from a string as an
  65.     index into an array, do care.  I have assumed that
  66.        _AlphabetSize = 128 => only 0..127 appear in strings
  67.        _AlphabetSize = 256 => only 0..255 appear in strings
  68.     The files _str2set.c and _str2map.c declare character vectors  using
  69.     this  size.  If you don't have unsigned char, your machine may treat
  70.     char as unsigned anyway.
  71.  
  72.     Some string operations (*cmp, *chr) are explicitly defined in various
  73.     UNIX manuals to use "native" comparison, so I have not used _char_ in
  74.     them.  This package is meant to be compatible, not rational!
  75. */
  76.  
  77. extern char    *strcat(/*char^,char^*/);
  78. extern char    *strncat(/*char^,char^,int*/);
  79.  
  80. extern int     strcmp(/*char^,char^*/);
  81. extern int     strncmp(/*char^,char^,int*/);
  82.  
  83. #define streql !strcmp
  84. #define strneql        !strncmp        /* (str-N)-eql not str-(neq-l)! */
  85.  
  86. extern char    *strcpy(/*char^,char^*/);
  87. extern char    *strncpy(/*char^,char^,int*/);
  88.  
  89. extern int     strlen(/*char^*/);
  90. extern int     strnlen(/*char^,int*/);
  91.  
  92. extern char    *strchr(/*char^,_char_*/);
  93. extern char    *strrchr(/*char^,_char_*/);
  94. #define        index   strchr
  95. #define        rindex  strrchr
  96.  
  97. extern char    *strmov(/*char^,char^*/);
  98. extern char    *strnmov(/*char^,char^,int*/);
  99.  
  100. extern void    strrev(/*char^,char^*/);
  101. extern void    strnrev(/*char^,char^,int*/);
  102.  
  103. extern char    *strend(/*char^*/);
  104. extern char    *strnend(/*char^*/);
  105.  
  106. extern char    *strpbrk(/*char^,char^*/);
  107. extern char    *strcpbrk(/*char^,char^*/);
  108.  
  109. extern int     strspn(/*char^,char^*/);
  110. extern int     strcspn(/*char^,char^*/);
  111.  
  112. extern char    *strtok(/*char^,char^*/);
  113. extern void    istrtok(/*char^,char^*/);
  114.  
  115. extern char    *strpack(/*_char_^,_char_^,char^,int*/);
  116. extern char    *strcpack(/*_char_^,_char_^,char^,int*/);
  117.  
  118. extern int     strrpt(/*char^,char^,int*/);
  119. extern int     strnrpt(/*char^,int,char^,int*/);
  120.  
  121. extern void    strtrans(/*_char_^,_char_^,_char_^,_char_^*/);
  122. extern       void    strntrans(/*_char_^,_char_^,int,_char_^,_char_^*/);
  123.  
  124. extern char    *strtrim(/*char^,char^,char^,int*/);
  125. extern char    *strctrim(/*char^,char^,char^,int*/);
  126.  
  127. extern char    *strfield(/*char^,int,int,int,int*/);
  128. extern char    *strkey(/*char^,char^,char^,char^*/);
  129.  
  130. extern char    *strfind(/*char^,char^*/);
  131. extern char    *strrepl(/*char^,char^,char^,char^*/);
  132.  
  133. extern void    bcopy(/*char^,char^,int*/);
  134. extern void    bmove(/*char^,char^,int*/);
  135.  
  136. extern void    bfill(/*char^,int,char*/);
  137. extern void    bzero(/*char^,int*/);
  138.  
  139. extern int     bcmp(/*char^,char^,int*/);
  140. #define        beql    !bcmp
  141.  
  142. extern int     ffs(/*int*/);
  143. extern int     ffc(/*int*/);
  144.  
  145. extern       char    *substr(/*char^,char^,int,int*/);
  146.  
  147. extern char    *strxcat(/*VARARGS*/);
  148. extern char    *strxcpy(/*VARARGS*/);
  149. extern char    *strxmov(/*VARARGS*/);
  150.  
  151. extern char    *strxncat(/*VARARGS*/);
  152. extern char    *strxncpy(/*VARARGS*/);
  153. extern char    *strxnmov(/*VARARGS*/);
  154.  
  155. #endif NullS
  156.  
  157. #ifndef        memeql
  158. #include "memory.h"
  159. #endif memeql
  160.  
  161.